<template>
   <el-card>
      <!-- 教师管理 -->
      <bread-crumb slot="header">
        <template slot="title">教师管理</template>
      </bread-crumb>
      <div class="Contaner">
          <div class="QueryBtn">
            <el-select v-model="value" placeholder="请选择" style=" width: 170px;">
              <el-option
                v-for="item in options"
                :key="item.value"
                :label="item.label"
                :value="item.value">
              </el-option>
            </el-select>
            <el-input v-model="input" placeholder="请输入内容" style="width: 210px;margin-left: 20px;"></el-input>
              <el-button style="margin-left: 20px; height: 25px; line-height: 3px;" type="primary" @click="listTeacherReview(value)">查询</el-button>
              <!-- <el-button @click="exportBouncedsss = true" style="margin-left: 20px; height: 25px; line-height: 3px;" type="text">高级搜索</el-button> -->
          </div>
        <el-tabs type="border-card">
          <el-tab-pane label="教师查询">
             <!-- <el-button @click="exportBounced = true" type="primary" style="margin-bottom: 16px; margin-top: 15px;">导出数据</el-button> -->
              <el-table :header-cell-style="{ background: '#eee', color: '#606266' }" :data="tableData"  max-height="450" style="width: 100%">
                <el-table-column label="教师头像" width="180%">
                  <template slot-scope="{row}">
                    <img width="45px" height="45px" :src="`/api/v1/pri/util/showPic?fileId=${row.headPic}`" alt="">
                  </template>
                </el-table-column>
                <!--  -->
                <el-table-column label="姓名" width="140%">
                  <template slot-scope="{row}">
                    <el-button
                    @click="lookOverInfo(row)"
                      type="text"
                      size="small">
                      {{row.name}}
                    </el-button>
                  </template>
                </el-table-column>
                <el-table-column prop="servicesName" label="所属机构" width="140%"></el-table-column>
                <el-table-column prop="teacherTypeName" label="教师资格种类" width="140%"></el-table-column>
                <el-table-column prop="teacherTypeNum" label="教师资格证号" width="140%"></el-table-column>
                <el-table-column prop="subjectName" label="任教学科" width="140%"></el-table-column>
                <el-table-column label="教师资格证审核" width="140%" :filters="[{text: '有', value: '1'},{text: '无', value: '2'}]" :filter-method="filterHandler">
                  <template slot-scope="{row}">
                    <p>
                      {{row.teacherTypeExamine === 0 ? "无" : row.teacherTypeExamine === 2 ? '有' : '无' }}
                    </p>
                  </template>
                </el-table-column>
                <el-table-column prop="licence" label="是否在职在编" width="140%" :filters="[{text: '不在职在编', value: '1'},{text: '在职在编', value: '2'}]" :filter-method="filterHandler">
                  <template slot-scope="{row}">
                    <p>
                      {{row.workType === 1 ? "专职" : '兼职' }}
                    </p>
                  </template>
                </el-table-column>
                <el-table-column label="是否被冻结" width="140%" :filters="[{text: '为被冻结', value: '1'},{text: '被冻结', value: '2'}]" :filter-method="filterHandler">
                  <template slot-scope="{row}">
                    <p>
                      {{row.status === 2 ? "冻结" : '否' }}
                    </p>
                  </template>
                </el-table-column>
                <el-table-column label="办件类型" width="140%">
                  <template slot-scope="{row}">
                    <p>
                      {{row.reviewType === 'add' ? "新增" : '注销' }}
                    </p>
                  </template>
                </el-table-column>
                <el-table-column prop="licence" label="审批类型" width="140%" :filters="[{text: '手动审批', value: '1'},{text: '自动校验', value: '2'}]" :filter-method="filterHandler">
                  <template slot-scope="{row}">
                    <p>
                      {{row.reviewStatus === 0 ? "未通过" : row.reviewStatus === 1 ? '待审核' : '已通过' }}
                    </p>
                  </template>
                </el-table-column>
              </el-table>
              <!-- 分页 -->
                <el-row
                  type="flex"
                  align="middle"
                  justify="end"
                  style="margin-top: 20px"
                >
                  <el-col :span="12">
                    <el-pagination
                      background
                      layout="total, prev, pager, next, sizes"
                      :total="page.total"
                      :page-sizes="[7, 10, 20, 50, 100]"
                      :page-size="page.pageSize"
                      @current-change="changePage"
                      @size-change="handleSizeChange"
                      :current-page.sync="page.currentPage"
                    ></el-pagination>
                  </el-col>
                </el-row>
          </el-tab-pane>
          <el-tab-pane label="教师审批">
            <div class="Selectionsss">
              <div class="left_btn">
               <el-button plain @click="listTeacherReview()">全部</el-button>
               <el-button plain @click="listTeacherReview('待审批')">待审批</el-button>
               <el-button plain @click="listTeacherReview('已通过')">已通过</el-button>
               <el-button plain @click="listTeacherReview('未通过')">未通过</el-button>
              </div>
              <div class="right_shenhe" v-show="true">
                <el-button type="success" @click="doTeacherReview">批量通过</el-button>
                <el-button type="danger" @click="stipo">批量不通过</el-button>
              </div>
            </div>
              <el-table :header-cell-style="{ background: '#eee', color: '#606266' }" :data="tableData"  max-height="450" style="width: 100%"
              tooltip-effect="dark"
              @selection-change="handleSelectionChange"
              >
              <el-table-column type="selection" width="55"> </el-table-column>
                <el-table-column prop="" label="教师头像" width="180%">
                  <template slot-scope="{row}">
                    <img width="45px" height="45px" :src="`/api/v1/pri/util/showPic?fileId=${row.headPic}`" alt="">
                  </template>
                </el-table-column>
                <el-table-column label="姓名" width="140%">
                  <template slot-scope="{row}">
                    <el-button
                    @click="lookOverInfo(row)"
                      type="text"
                      size="small">
                      {{row.name}}
                    </el-button>
                  </template>
                </el-table-column>
                <el-table-column prop="servicesName" label="所属机构" width="140%"></el-table-column>
                <el-table-column prop="teacherTypeName" label="教师资格种类" width="140%"></el-table-column>
                <el-table-column prop="teacherTypeNum" label="教师资格证号" width="140%"></el-table-column>
                <el-table-column prop="subjectName" label="任教学科" width="140%"></el-table-column>
                <el-table-column prop="licence" label="教师资格证审核" width="140%" :filters="[{text: '有', value: '1'},{text: '无', value: '2'}]" :filter-method="filterHandler">
                  <template slot-scope="{row}">
                    <p>
                      {{row.teacherTypeExamine === 0 ? "无" : row.teacherTypeExamine === 2 ? '有' : '无' }}
                    </p>
                  </template>
                </el-table-column>
                <el-table-column prop="licence" label="是否在职在编" width="140%" :filters="[{text: '不在职在编', value: '1'},{text: '在职在编', value: '2'}]" :filter-method="filterHandler">
                  <template slot-scope="{row}">
                    <p>
                      {{row.workType === 1 ? "专职" : '兼职' }}
                    </p>
                  </template>
                </el-table-column>
                <el-table-column prop="licence" label="是否被冻结" width="140%" :filters="[{text: '为被冻结', value: '1'},{text: '被冻结', value: '2'}]" :filter-method="filterHandler">
                 <template slot-scope="{row}">
                    <p>
                      {{row.status === 2 ? "冻结" : '否' }}
                    </p>
                  </template>
                </el-table-column>
                <el-table-column prop="licence" label="审批类型" width="140%" :filters="[{text: '手动审批', value: '1'},{text: '自动校验', value: '2'}]" :filter-method="filterHandler">
                  <template slot-scope="{row}">
                    <p>
                      {{row.reviewStatus === 0 ? "未通过" : row.reviewStatus === 1 ? '待审核' : '已通过' }}
                    </p>
                  </template>
                </el-table-column>
              </el-table>
              <!-- 分页 -->
                <el-row
                  type="flex"
                  align="middle"
                  justify="end"
                  style="margin-top: 20px"
                >
                  <el-col :span="8">
                    <el-pagination
                      background
                      layout="total, prev, pager, next, sizes"
                      :total="page.total"
                      :page-sizes="[7, 10, 20, 50, 100]"
                      :page-size="page.pageSize"
                      @current-change="changePage"
                      @size-change="handleSizeChange"
                      :current-page.sync="page.currentPage"
                    ></el-pagination>
                  </el-col>
                </el-row>
          </el-tab-pane>
        </el-tabs>
      </div>
      <!-- 导出弹框 -->
      <el-dialog title="导出数据" width="500px" :visible.sync="exportBounced">
        <div class="ExportBtn">
          <el-button type="primary">导出当前页</el-button>
          <el-button style="margin-left: 60px" type="primary"
            >导出全部数据（搜索后）</el-button
          >
        </div>
      </el-dialog>
      <!-- 高级搜索 -->
      <el-dialog title="高级搜索" width="700px" :visible.sync="exportBouncedsss">
        <div class="Top_seach">
          <p>学科筛选 </p>
          <div class="category">
            <div>学科类别（多选）：</div>
            <div style="margin-left: 10px;" class="checkboxs">
              <el-checkbox v-model="checked">语文</el-checkbox>
              <el-checkbox v-model="checked">数学</el-checkbox>
              <el-checkbox v-model="checked">英语</el-checkbox>
              <el-checkbox v-model="checked">科学</el-checkbox>
              <el-checkbox v-model="checked">技术</el-checkbox>
              <el-checkbox v-model="checked">历史与社会</el-checkbox>
              <el-checkbox v-model="checked">物理</el-checkbox>
              <el-checkbox v-model="checked">化学</el-checkbox>
              <el-checkbox v-model="checked">生物</el-checkbox>
              <el-checkbox v-model="checked">地理</el-checkbox>
              <el-checkbox v-model="checked">政治</el-checkbox>
              <el-checkbox v-model="checked">历史</el-checkbox>
              <el-checkbox v-model="checked">其他</el-checkbox>
            </div>
          </div>
          <p>时间筛选</p>
          <div class="blocksss">
            <span class="demonstration">申报时间：</span>
            <el-date-picker
              v-model="value1"
              type="date"
              placeholder="选择日期">
            </el-date-picker>
          </div>
          <p>组合搜索</p>
          <div class="tabelskc"><div class="left_name">姓名：</div><div class="shuru"><el-input /></div></div>
          <div class="tabelskc"><div class="left_name">身份证号码：</div><div class="shuru"><el-input /></div></div>
          <div class="tabelskc"><div class="left_name">教师资格证号：</div><div class="shuru"><el-input /></div></div>
          <div class="tabelskc"><div class="left_name">教师资格种类：</div><div class="shuru">
              <el-select v-model="value" placeholder="请选择" style="width: 100%;">
                <el-option
                  v-for="item in optionsskc"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value">
                </el-option>
              </el-select>
            </div></div>
        </div>
        <span slot="footer" class="dialog-footer">
          <el-button @click="exportBouncedsss = false">取 消</el-button>
          <el-button type="primary" @click="exportBouncedsss = false">确 定</el-button>
        </span>
      </el-dialog>
      <!-- 详细信息 -->
      <el-dialog title="详细信息" width="600px" :visible.sync="exportBouncedsssss">
        <div class="big_Info"><div>教师名称：</div><div style="margin-left: 2px;">{{ teacherInfoMsg.name }}</div></div>
        <div class="big_Info"><div>身份证件类型：</div><div style="margin-left: 2px;">{{ teacherInfoMsg.documentTypeName }}</div></div>
        <div class="big_Info"><div>身份证件号码：</div><div style="margin-left: 2px;">{{ teacherInfoMsg.documentNum }}</div></div>
        <div class="big_Info"><div>教师资格种类：</div><div style="margin-left: 2px;">{{ teacherInfoMsg.teacherTypeName }}</div></div>
        <div class="big_Info"><div>任教学科：</div><div style="margin-left: 2px;">{{ teacherInfoMsg.subjectName }}</div></div>
        <div class="big_Info"><div>情况说明：</div><div style="margin-left: 2px;">{{ teacherInfoMsg.NaNpxarks }}</div></div>
        <div class="big_Info"><div>证明材料：</div><div style="margin-left: 2px;">
          <el-image style="width:55px;height: 55px;margin-left: 15px;" v-for="item in teacherInfoMsg.supportingMaterialsPic" :key="item" :src="`/api/v1/pri/util/showPic?fileId=${item}`" :preview-src-list="viewLargerImage(teacherInfoMsg.supportingMaterialsPic)" alt=""></el-image>
          </div></div>
        <div class="big_Info"><div>教师头像：</div><div style="margin-left: 2px;">
          <el-image :preview-src-list="[`/api/v1/pri/util/showPic?fileId=${teacherInfoMsg.headPic}`]" :src="`/api/v1/pri/util/showPic?fileId=${teacherInfoMsg.headPic}`" alt=""></el-image>
        </div></div>
      </el-dialog>
   </el-card>
</template>

<script>
import { listTeacherReview, doTeacherReview } from '@/api'
export default {
  data () {
    return {
      exportBouncedsssss: false,
      exportBounced: false,
      exportBouncedsss: false,
      optionsskc: [{
        value: '选项1',
        label: '初级中学教师资格证'
      }, {
        value: '选项2',
        label: '高级中学教师资格证'
      }, {
        value: '选项3',
        label: '小学教师资格证'
      }, {
        value: '选项4',
        label: '高等学校教师资格证'
      }],
      options: [{
        value: '姓名',
        label: '姓名'
      }, {
        value: '身份证号码',
        label: '身份证号码'
      }, {
        value: '教师资格证号',
        label: '教师资格证号'
      }, {
        value: '所属机构',
        label: '所属机构'
      }],
      value: '',
      value1: '',
      input: '',
      page: {
        // 分页数据
        total: 1000, // 总条数
        currentPage: 1, // 默认的页码 是第一个页  决定了当前页码是第几页
        pageSize: 9 // page-size的默认值是10条
      },
      tableData: [],
      teacherInfoMsg: {},
      multipleSelection: []
    }
  },
  created () {
    this.listTeacherReview()
  },
  methods: {
    // 批量拒绝
    stipo () {
      this.$prompt('请输入拒绝理由', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消'
      }).then(async ({ value }) => {
        if (value === null || value === '') {
          this.$message({
            type: 'error',
            message: '请输入原因'
          })
          return false
        }
        const a = this.multipleSelection.map((item) => {
          return item.id
        })
        const data = {
          idList: a,
          reviewStatus: 0,
          reviewRemarks: value
        }
        const ser = await doTeacherReview(data)
        if (ser.code === 200) {
          this.$message.success(ser.msg)
          this.listTeacherReview()
        }
      })
    },
    // 批量通过
    async doTeacherReview () {
      const a = this.multipleSelection.map((item) => {
        return item.id
      })
      const data = {
        idList: a,
        reviewStatus: 2
      }
      const ser = await doTeacherReview(data)
      if (ser.code === 200) {
        this.$message.success(ser.msg)
        this.teachingSchool()
      }
    },
    // 查看大图数据处理
    viewLargerImage (items) {
      const a = JSON.parse(items)
      const b = a.map((item) => {
        return `/api/v1/pri/util/showPic?fileId=${item}`
      })
      return b
    },
    // 请求数据列表
    async listTeacherReview (type) {
      let data = {}
      switch (type) {
        case '待审批':
          data = { reviewStatus: 1 }
          break
        case '未通过':
          data = { reviewStatus: 0 }
          break
        case '已通过':
          data = { reviewStatus: 2 }
          break
        case '姓名':
          data = { name: this.input }
          break
        case '身份证号码':
          data = { documentNum: this.input }
          break
        case '教师资格证号':
          data = { teacherTypeNum: this.input }
          break
        case '所属机构':
          data = { servicesName: this.input }
          break

        default:
          break
      }
      const ser = await listTeacherReview({ reviewStatus: null, ...data })
      if (ser?.code === 200) {
        const { list, total } = ser?.data
        this.tableData = list
        this.page.total = total
      }
    },
    // 查看教师详情
    lookOverInfo (item) {
      this.teacherInfoMsg = item
      this.exportBouncedsssss = true
    },
    // 当选择项发生变化时会触发该事件
    handleSelectionChange (val) {
      console.log('我选择了')
      console.log(val)
      this.multipleSelection = val
    }
  }
}
</script>

<style lang="less" scopde>
  .Selectionsss {
    padding-top: 10px;
    padding-bottom: 26px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    .left_btn {

      .el-button+.el-button {
        margin-left: 0;
    }
      }
  }
  .big_Info {
    display: flex;
    padding: 0 24px 16px;
    color: rgba(0,0,0,.85);
  }
.Top_seach {
  .tabelskc {
    display: flex;
      margin-bottom: 24px;
    .shuru {
      width: 100%;
    }
    .left_name {
      width: 180px;
      height: 32px;
      text-align: right;
      line-height: 32px;
    }
  }
      .blocksss {
      padding: 0 0 0 75px;
      margin-bottom: 24px;
    }
  .category {
    padding: 0 0 0 20px;
    display: flex;
    align-items: center;
    margin-bottom: 24px;
    .checkboxs {
      width: 500px;
      display: flex;
      flex-wrap: wrap;
      .el-checkbox {
        margin-right: 15px;
      }
    }
  }
  p {
    margin-bottom: 10px;
    font-weight: 600;
    font-size: 20px;
    color: #000000;
  }
}
  .ExportBtn {
    width: 80%;
    margin: 0px 40px 0px;
    padding-bottom: 40px;
  }
  .el-card__body {
    padding: 0 !important;

      .el-dialog {
    margin-bottom: 0 !important;
  }

  .el-dialog__body {
    padding: 30px 20px 0;
    border-top: 1px solid #e4e4e4;
  }
  }
  .Contaner {
    position: relative;
  }
  .QueryBtn {
    display: flex;
    align-items: center;
    width: 550px;
    height: 40px;
    position: absolute;
    top: 0;
    right: 30px;
    z-index: 1;
    .el-input__suffix {
      line-height: 50px;
    }
    input {
      height: 30px;
    }
  }
</style>
